import java.io.FileNotFoundException;
import java.nio.file.FileAlreadyExistsException;
import java.util.InputMismatchException;
import java.util.Scanner;

/*public static void Open(String file){
    if(file.equals)
        }*/

public class Test {
    public static int func() {
        try{
            return 10;

        }finally{
            return 20;
        }
    }
    public static void main(String[] args) {
        System.out.println(func());
        /*try{
            return 10;

        }finally{

        }*/
    }
    public static void main4(String[] args) {
        Scanner scanner = new Scanner(System.in);
        try{
            int a = scanner.nextInt();
            System.out.println(a);
        }catch(InputMismatchException e){
            e.printStackTrace();
        }finally{
            System.out.println("finally执行了");
            scanner.close();
        }
    }
    public static void main3(String[] args) {
        try{
            int[] arr = {1,2,4};
            arr[33] = 9;
            arr = null;
            System.out.println(arr.length);

        }/*catch(RuntimeException e) {*/

       /* }*/ catch(NullPointerException e){
            System.out.println("捕获了NullPointerException");
            e.printStackTrace();
        }catch(ArrayIndexOutOfBoundsException e){
            System.out.println("捕获了ArrayIndexOutOfBoundsException异常");
            e.printStackTrace();
        }catch(RuntimeException e){
            System.out.println("jjjs");
        }finally{
            System.out.println("finally被执行了");
        }
    }
    public static void Open(String file)throws FileNotFoundException{
        if(file.equals("int")){
            throw new FileNotFoundException("配置文件不对");

        }
    }

    public static void main2(String[] args) throws FileNotFoundException{
        //Open("int");是因为main方法中没有对异常进行抛出；
        try{
            Open("int");
            System.out.println("哈哈哈");
        }/*catch(FileNotFoundException e){
            System.out.println("捕获了FileNotFoundException异常，开始处理异常");
            e.printStackTrace();*/
       /* }*/
        catch(NullPointerException e){

        }
        System.out.println("异常处理完毕");
    }
    public static void main1(String[] args) throws CloneNotSupportedException,FileNotFoundException{
        int[] arr = {1,2,3,4,5};
        System.out.println(arr[10]);

        int a = 10;
        if(a == 10){
            throw new CloneNotSupportedException();//抛出的是编译时异常 必须先处理

        }if(a == 9){
            throw new FileNotFoundException();
        }
    }
}
